package com.stony.listener;

import org.springframework.web.util.WebAppRootListener;
import org.springframework.web.util.WebUtils;

import javax.servlet.ServletContextEvent;

/**
 * Created by ShiHui on 2014/6/12.
 */
public class WebAppRootListenerExt extends WebAppRootListener {


    public static final String DEFAULT_WEB_PATH_KEY = "web.path";

    public void contextInitialized(ServletContextEvent event) {
        super.contextInitialized(event);
        System.setProperty(DEFAULT_WEB_PATH_KEY, event.getServletContext().getContextPath());
    }

    public void contextDestroyed(ServletContextEvent event) {
        super.contextDestroyed(event);
        System.getProperties().remove(DEFAULT_WEB_PATH_KEY);
    }
}
